﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using NCS.IConnect.ApplicationContexts;
using JM.JCY.Proxy;
using JM.JCY.BusinessEntity;
using Microsoft.SharePoint;

namespace JM.JCY.SharePointComponent.Event.CreateEvent
{
    public partial class CreateEventUserControl : UserControl
    {
       

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                dtEndDateFrom.SelectedDate = DateTime.Today;
            }
        }

        protected void imgSavePublish_Click(object sender, ImageClickEventArgs e)
        {
            EventDataset.T_EventDataTable eventDT = new EventDataset.T_EventDataTable();


            EventDataset.T_EventRow newEvent = eventDT.NewT_EventRow();
            newEvent.Subject = this.txtSubject.Text;
            newEvent.EventContent = this.txtSummary.Text;
            newEvent.UserName = SPContext.Current.Web.CurrentUser.Name;
            newEvent.EndDate = this.dtEndDateFrom.SelectedDate;
            newEvent.Status = "未完成";
            JCY.Common.JCYUtility.UpdateCommonFields(newEvent, "admin");
            eventDT.AddT_EventRow(newEvent);
            using (EventProxy eventProxy = new EventProxy())
            {
                eventProxy.UpdateEvent(eventDT);
            }
            Response.Redirect("SearchEventSender.aspx");
        }

        protected void imgCancel_Click(object sender, ImageClickEventArgs e)
        {
            Response.Redirect("SearchEventSender.aspx");
        }

       
        
    }
}
